home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kmultipledrag.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  3.3 KB  |  106 lines

  1. /* This file is part of the KDE project
  2.    Copyright (C) 2001 David Faure <faure@kde.org>
  3.  
  4.    This program is free software; you can redistribute it and/or
  5.    modify it under the terms of the GNU Library General Public
  6.    License as published by the Free Software Foundation; either
  7.    version 2 of the License.
  8.  
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.    Library General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU Library General Public License
  15.    along with this program; see the file COPYING.  If not, write to
  16.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17.    Boston, MA 02110-1301, USA.
  18. */
  19.  
  20. #ifndef KMULTIPLEDRAG_H
  21. #define KMULTIPLEDRAG_H
  22.  
  23. #ifndef QT_NO_DRAGANDDROP
  24.  
  25. #include <qdragobject.h>
  26. #include <qvaluelist.h>
  27. #include "kdelibs_export.h"
  28.  
  29. class KMultipleDragPrivate;
  30. /**
  31.  * This class makes it easy for applications to provide a drag object
  32.  * (for drag-n-drop or for clipboard) that has several representations
  33.  * of the same data, under different formats.
  34.  *
  35.  * Instead of creating a specific class for each case (as would otherwise
  36.  * be necessary), you can simply create independent drag objects (e.g.
  37.  * a QImageDrag object and a KURLDrag object), and bundle them together
  38.  * using KMultipleDrag.
  39.  *
  40.  * Sample code for this:
  41.  *
  42.  * \code
  43.  * KMultipleDrag *drag = new KMultipleDrag( parentWidget );
  44.  * drag->addDragObject( new QImageDrag( someQImage, 0 ) );
  45.  * drag->addDragObject( new KURLDrag( someKURL, 0 ) );
  46.  * drag->drag();
  47.  * \endcode
  48.  *
  49.  * Note that the drag objects added to the multiple drag become owned by it.
  50.  * For that reason their parent should be 0.
  51.  *
  52.  * @author David Faure <faure@kde.org>
  53.  */
  54. class KDECORE_EXPORT KMultipleDrag : public QDragObject
  55. {
  56.     Q_OBJECT
  57.  
  58. public:
  59.     /**
  60.      * Create a new KMultipleDrag object.
  61.      * @param dragSource the parent object which is the source of the data,
  62.      *                   0 for a parent-less object
  63.      * @param name the name of the object, can be 0
  64.      */
  65.     KMultipleDrag( QWidget *dragSource = 0, const char *name = 0 );
  66.  
  67.     /**
  68.      * Call this to add each underlying drag object to the multiple drag object.
  69.      * The drag object should not have a parent because the multiple drag object
  70.      * will own it.
  71.      *
  72.      * @param dragObject the drag object to add. Should have no parent object.
  73.      */
  74.     void addDragObject( QDragObject *dragObject );
  75.  
  76.     /**
  77.      * Returns the data of a drag object with that supports the given
  78.      * mime type.
  79.      * @param mime the mime type to search
  80.      * @return the data, or a null byte array if not found
  81.      * @reimp
  82.      */
  83.     virtual QByteArray encodedData( const char *mime ) const;
  84.  
  85.     /**
  86.      * Returns the @p i'th supported format, or 0.
  87.      * @param i the number of the format to check
  88.      * @return the format with the number @p i, or 0 otherwise
  89.      * @reimp
  90.      */
  91.     virtual const char* format( int i ) const;
  92.  
  93. protected:
  94. // KDE4: make private
  95.     QPtrList<QDragObject> m_dragObjects;
  96.     QValueList<int> m_numberFormats;
  97. protected:
  98.     virtual void virtual_hook( int id, void* data );
  99. private:
  100.     KMultipleDragPrivate* d;
  101. };
  102.  
  103. #endif // QT_NO_DRAGANDDROP
  104.  
  105. #endif // KMULTIPLEDRAG_H
  106.